package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.admin.Analysis;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AnalysisMapper extends BaseMapper<Analysis> {
    @Select("select sum(num_registered) from tb_analysis_by_day")
    Integer queryCumulativeUsers();

    @Select("select * from tb_analysis_by_day where record_date between SUBDATE(#{sd},interval 1 year)and SUBDATE(#{ed},interval 1 year)")
    List<Analysis> findLastYear(@Param("sd") String sd, @Param("ed") String ed);

    @Select("select sum(num_active) from tb_analysis_by_day where DATEDIFF(record_date,NOW())<=0 AND DATEDIFF(record_date,NOW())>-1*(#{days})")
    Integer querynum30(@Param("days") Integer days);

    @Select("select count(#{type}) from tb_analysis_by_day where record_date=#{today} ")
    Integer queryToday(@Param("today") String today,@Param("type") String type);

}

